﻿/**
 * Peter
 * Created by: Peter Development Team
 *    http://peter.codeplex.com/
 * 
 * GNU General Public License version 2 (GPLv2)
 *    http://peter.codeplex.com/license
 *
 *  This code is provided on an AS IS basis, with no WARRANTIES,
 *  CONDITIONS or GUARANTEES of any kind.
 *  
 **/

using System.IO;
using Peter.Common.Code;
using Peter.Common.Tree;

namespace Peter.Common
{
   /// <summary>
   /// Represents a project for peter.
   /// </summary>
   public class PeterProjectItem : FileTreeViewItem
   {
      private bool m_IsCurrentProject;
      private bool m_CanBeCurrentProject;

      /// <summary>
      /// Initializes a new peter project.
      /// </summary>
      /// <param name="parent">Parent item</param>
      public PeterProjectItem (ModelTreeViewItem parent)
         : base (parent, false)
      {
      }

      /// <summary>
      /// Initializes a new peter project.
      /// </summary>
      /// <param name="parent">Parent item</param>
      /// <param name="file">The file for this item.</param>
      public PeterProjectItem (ModelTreeViewItem parent, FileInfo file)
         : base (parent, file)
      {
      }

      /// <summary>
      /// Initializes a new peter project.
      /// </summary>
      /// <param name="parent">Parent item</param>
      /// <param name="directory">The directory for this item.</param>
      public PeterProjectItem (ModelTreeViewItem parent, DirectoryInfo directory)
         : base (parent, directory, false)
      {
      }

      /// <summary>
      /// Gets or Sets if this can be set as a current project.
      /// </summary>
      public bool CanBeCurrentProject
      {
         get { return this.m_CanBeCurrentProject; }
         set
         {
            this.m_CanBeCurrentProject = value;
            this.OnPropertyChanged ("CanBeCurrentProject");
         }
      }
      
      /// <summary>
      /// Gets or Sets if this is the current project.
      /// </summary>
      public bool IsCurrentProject
      {
         get { return this.m_IsCurrentProject; }
         set
         {
            this.m_IsCurrentProject = value;
            this.OnPropertyChanged ("IsCurrentProject");
         }
      }

      /// <summary>
      /// Gets the code completion for the project.
      /// </summary>
      public  PeterProjectItem ParentProject { get; set; }

      /// <summary>
      /// Gets the code completion for the project.
      /// </summary>
      public virtual BaseCodeCompletion CodeCompletion { get; set; }

      /// <summary>
      /// Sets if this is the current project or not.
      /// </summary>
      /// <param name="isCurrent">True if current, false if removing current flag.</param>
      public virtual void SetCurrentProject (bool isCurrent)
      {
         this.IsCurrentProject = isCurrent;
      }

      /// <summary>
      /// Occurs when the Peter application is closing.
      /// </summary>
      public virtual void PeterClosing () {}
   }
}
